import Vue from 'vue'
import App from './App.vue'
import Vant from 'vant';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import moment from "moment"
import 'vant/lib/index.css';
import { Lazyload } from 'vant';
import { serveUrL } from "@/utils/request"

import store from "@/store"
import router from './router'

Vue.config.productionTip = false
Vue.use(Vant);
Vue.use(Lazyload);
Vue.use(moment);
Vue.use(ElementUI);

// 定义全局过滤器
Vue.filter("diaImg",(val)=>{
   if(val) {
      if(val.startsWith("http")) {
         return val
      } else {
         return serveUrL+val;
      }
   } else {
      return "https://img2.baidu.com/it/u=2677371789,2325844193&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"
   }
})

// 定义全局过滤器将价格单位确定
Vue.filter("priDia",(price)=>{
    return price*100
})
//定义全局时间格式化过滤
Vue.filter("forTime",(timer)=>{
     return moment(timer).format("YYYY-MM-DD");
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
